package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.SeeRecordHistoryRequest;
import one.stand.request.SeeRecordRequest;
import one.stand.request.statistics.*;
import one.stand.response.CrmCustomerAnalysisRespnse;
import one.stand.response.CrmSeeRecordResponse;
import one.stand.response.SeeRecordHistoryResponse;
import one.stand.response.statistics.SceneVisitStatisticsResponse;
import one.stand.response.statistics.SituationVisitStatisticsResponse;
import one.stand.response.statistics.TimeVisitStatisticsResponse;
import one.stand.response.statistics.VisitGoodsTopResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Administrator
 */
@RequestMapping("crmApi/seeRecord")
@RestController
@Api(description = "查看记录系列",tags="查看记录系列")
public class SeeRecordController extends BaseController {

    // 访问概况
    @ApiOperation("今日概况")
    @ApiImplicitParams({})
    @ApiController(isLogin = true, company = true, card = true, paramClass = SituationVisitStatisticsRequest.class)
    @PostMapping("situationStatistics")
    public ResultModel<SituationVisitStatisticsResponse> situationStatistics(@RequestAttribute SituationVisitStatisticsRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.situationStatistics(request);
    }

    // 时间折现图
    @ApiOperation("时间折现图统计")
    @ApiImplicitParams({ @ApiImplicitParam(name = "timeType", value = "统计类型0:今日;1:昨日;2:7天;3:30天", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "businessType", value = "业务类型1:名片;2:产品;3：官网;4:查看文章;5:预约", required = true, paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = TimeVisitStatisticsRequest.class)
    @PostMapping("timeStatistics")
    public ResultModel<TimeVisitStatisticsResponse> timeStatistics(@RequestAttribute TimeVisitStatisticsRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.timeStatistics(request);
    }

    @ApiOperation("场景值统计")
    @ApiImplicitParams({ @ApiImplicitParam(name = "timeType", value = "统计类型0:今日;1:昨日;2:7天;3:30天", required = true, paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = SceneVisitStatisticsRequest.class)
    @PostMapping("sceneStatistics")
    public ResultModel<SceneVisitStatisticsResponse> sceneStatistics(@RequestAttribute SceneVisitStatisticsRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.sceneStatistics(request);
    }

    @ApiOperation("访问排名")
    @ApiImplicitParams({ @ApiImplicitParam(name = "pageSize", value = "每页条数", required = false, paramType = "Integer"),
                         @ApiImplicitParam(name = "pageNum", value = "当前页", required = false, paramType = "Integer"),
                         @ApiImplicitParam(name = "seeType", value = "访问类型 0:全部,1:名片;2:产品;3：官网;4:查看文章;5:预约", required = true, paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = VisitRankingRequest.class)
    @PostMapping("getVisitRankingList")
    public ResultModel<List<CrmSeeRecordResponse>> getVisitRankingList(@RequestAttribute VisitRankingRequest request) {
        return crmFegin.getVisitRankingList(request);
    }

    @ApiOperation("商品访问TopN")
    @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "访客id", required = false, paramType = "Integer"),
                         @ApiImplicitParam(name = "timeType", value = "统计类型0:今日;1:昨日;2:7天;3:30天", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "topN", value = "topN", required = true, paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = VisitGoodsTopRequest.class)
    @PostMapping("getVisitGoodsTopN")
    public ResultModel<List<VisitGoodsTopResponse>> getVisitGoodsTopN(@RequestAttribute VisitGoodsTopRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.getVisitGoodsTopN(request);
    }

    @ApiOperation("圆饼图")
    @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "客户ID（用户客户分析）", paramType = "Integer"),
                         @ApiImplicitParam(name = "dayNum", value = "天数", paramType = "Integer"),
                         @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = SeeRecordRequest.class)
    @PostMapping("countCustomerAnalysis")
    public ResultModel<List<CrmCustomerAnalysisRespnse>> countCustomerAnalysis(@RequestAttribute SeeRecordRequest request) {

        return crmFegin.countCustomerAnalysis(request);
    }

    @ApiOperation("客户与我的互动")
    @ApiController(isLogin = true, company = true, card = true, paramClass = SeeRecordRequest.class)
    @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "客户ID（用于客户分析）", paramType = "Integer"),
                         @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", paramType = "Integer"), })
    @PostMapping("customerAnalysis")
    public ResultModel customerAnalysis(@RequestAttribute SeeRecordRequest request) {

        return crmFegin.customerAnalysis(request);
    }

    @ApiOperation("名片查看记录")
    @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "客户id（查询客户的各种记录）", paramType = "Integer"),
                         @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "entranceType", value = "入口类型（1:时间追踪，2：行为追踪，3：ai分析,4,成交率（查看类型必须是2））", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "seeType", value = "查看类型 1:名片，2:产品，3：官网,4:查看动态", paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = SeeRecordRequest.class)
    @PostMapping("getSeeRecordList")
    public ResultModel<List<CrmSeeRecordResponse>> getSeeRecordList(@RequestAttribute SeeRecordRequest request) {

        return crmFegin.getSeeRecordList(request);
    }

    @ApiOperation("商城访问概览")
    @ApiImplicitParams({ @ApiImplicitParam(name = "timeType", value = "统计类型0:今日;1:昨日;2:7天;3:30天", required = true, paramType = "Integer") })
    @ApiController(isLogin = true, company = true, card = true, paramClass = VisitMallStatisticsRequest.class)
    @PostMapping("visitMallStatistics")
    public ResultModel<VisitMallStatisticsResponse> visitMallStatistics(@RequestAttribute VisitMallStatisticsRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.visitMallStatistics(request);
    }

    @ApiOperation("预计成交率topN")
    @ApiImplicitParams({ @ApiImplicitParam(name = "timeType", value = "统计类型0:今日;1:昨日;2:7天;3:30天", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "topN", value = "topN", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "userId", value = "具体访问者的id", paramType = "Integer") })
    @ApiController(isLogin = true, company = true, card = true, paramClass = DealRateTopNRequest.class)
    @PostMapping("dealRateTopN")
    public ResultModel<List<DealRateTopNResponse>> dealRateTopN(@RequestAttribute DealRateTopNRequest request) {
        request.setCompanyId(request.getCId().intValue());
        return crmFegin.dealRateTopN(request);
    }

    @ApiOperation("客户互动记录")
    @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "客户id（查询客户的各种记录）", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"), })
    @ApiController(isLogin = true, company = true, card = true, paramClass = SeeRecordHistoryRequest.class)
    @PostMapping("getSeeRecordHistory")
    public ResultModel<List<SeeRecordHistoryResponse>> getSeeRecordHistory(@RequestAttribute SeeRecordHistoryRequest request) {
        return crmFegin.getSeeRecordHistory(request);
    }
}
